#include "RayTracing.h"
#include <QtWidgets/QApplication>
#include <qtextstream.h>
#include <qtranslator.h>
#include <Windows.h>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QFile f(":/qdarkstyle/dark/style.qss");
    QTranslator* translator = NULL,*systrans = NULL;
    translator = new QTranslator;
    systrans = new QTranslator;
    LANGID lang = GetUserDefaultLangID();
    switch (lang)
    {
    case 0x0804:
        if (translator->load(":/RayTracing/raytracing_zh.qm") && systrans->load(":/RayTracing/qt_zh_CN.qm"))
        {
            a.installTranslator(translator);
            a.installTranslator(systrans);
        }
        break;
    case 0x0409:
        if (translator->load(":/RayTracing/raytracing_en.qm"))
        {
            a.installTranslator(translator);
        }
        break;
    default:
        if (translator->load(":/RayTracing/raytracing_zh.qm"))
        {
            a.installTranslator(translator);
        }
        break;
    }


    if (!f.exists()) {
        printf("Unable to set stylesheet, file not found\n");
    }
    else {
        f.open(QFile::ReadOnly | QFile::Text);
        QTextStream ts(&f);
        a.setStyleSheet(ts.readAll());
        //a.setStyleSheet(ts.readAll());
        //w.setStyleSheet(ts.readAll());
    }
    RayTracing w;
    w.show();
    return a.exec();
}
